/*
 * matrix.h
 *
 *  Created on: Nov 20, 2013
 *      Author: cinus
 *
 *
 * i -> row
 * j -> column
 *
 * |a	b |
 * |c   d |  ---> | a c e b d f |
 * |e   f |
 *
 * a[1,2] = b
 * a[3,1] = e
 *
 */

#ifndef MATRIX_H_
#define MATRIX_H_

#include "types.h"

struct matrix {
	uint32 rows;
	uint32 cols;
	float32 *data;
};

typedef struct matrix matrix_t;

typedef matrix_t* matrix_tp;

matrix_tp newMatrix(uint32 rows, uint32 cols);
matrix_tp copyMatrix(matrix_tp src);

float32 get(matrix_tp m, uint32 i, uint32 j);

void set(matrix_tp m, uint32 i, uint32 j, float32 val);

void setColumn(matrix_tp m, uint32 i, float32* vector, int size);

matrix_tp t(matrix_tp m);

matrix_tp multiply(matrix_tp a, matrix_tp b);
matrix_tp hadamard(matrix_tp a, matrix_tp b);
matrix_tp add(matrix_tp a, matrix_tp b);
matrix_tp sub(matrix_tp a, matrix_tp b);
matrix_tp mulScalar(matrix_tp a, float32 scalar);
void zeros(matrix_tp m);
void printMatrix(matrix_tp m);

void freeData(matrix_tp m);
#endif /* MATRIX_H_ */
